#ifndef _BMAP_H
#define _BMAP_H

#include <stdint.h> // for uint64_t



/*
* lba file's format:
*    /path/to/file: 100(2), 500(5), 10000(10)
*   ...
*/
#ifdef SOURCE_INSIGHT
typedef unsigned long long int uint64_t;
#endif

/* File Mapping Extent */
struct bmap_extent{
	uint64_t offset;   
	uint64_t length;
	struct bmap_extent *next;
};

/* Infomation of File Block Mapping  */
struct bmap {
	char *filename;     //filename
	long blksize;   //file block size: 4096
	uint64_t blkcnt; // file blocks
	struct bmap_extent *head, *tail;
};

extern struct bmap *bmap_create(const char *filename, long blksize);
extern void bmap_destroy(struct bmap *p);
extern void bmap_append(struct bmap *p, uint64_t offset, uint64_t length);
extern struct bmap * bmap_load(FILE *fp);
extern void bmap_save(struct bmap *bm, FILE *fp);


#endif
